package msr.frontend;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import msr.object.DPLN;
import msr.service.OracleService;
import msr.util.DateParse;
import msr.util.RequestAction;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class HistoryController extends ActionSupport {

	/**
	 * 
	 */
	Map<String, Object> session = ActionContext.getContext().getSession();
	private String username;
	private String passwd;
	private static final long serialVersionUID = 1L;
	private List<DPLN> rtList = new ArrayList<DPLN>();
	private OracleService oService = new OracleService();

	public String execute() {
		this.setUsername((String) session.get("username"));
		this.setPasswd((String) session.get("passwd"));
		Map<String, Object> params = new HashMap<String, Object>();
		DateParse dParse = new DateParse();
		int date = Integer.parseInt(dParse.gettime());
		System.out.println("value of date " + date);
		params.put("date", date);
		rtList = oService.getListDpln(params, RequestAction.GET_ALL_DPLN);
		if (rtList == null) {
			addActionError(getText("error.historynotfound"));
			return ERROR;
		}
		return SUCCESS;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPasswd() {
		return passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

	public List<DPLN> getRtList() {
		return rtList;
	}

	public void setRtList(List<DPLN> rtList) {
		this.rtList = rtList;
	}

}
